<%@ page language="java" import="dao.*" pageEncoding="UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<%@page import="util.*" %>
<%@ include file="head.jsp" %>

<script src="js/jquery.validate.js"></script>
<script>
    window.searchSelectUrl = "ajax.jsp?a=selectUpdate";
    window.selectUpdateUrl = "ajax.jsp?a=table";
</script>
<script src="js/selectUpdate.js"></script>

<div style="padding: 10px" class="admin-content">
    <% if (request.getSession().getAttribute("username") == null || "".equals(request.getSession().getAttribute("username"))) { %>

    <script>
        alert("对不起,请您先登陆!");
        location.href = "login.jsp";
    </script>
    <%
            return;
        }
    %> <% if (null == request.getParameter("id") || "".equals(request.getParameter("id"))) { %>

    <script>
        alert("非法操作");
        history.go(-1);
    </script>
    <% out.close(); %>
    <%} %>
    <% Map readMap = Query.make("kechengxinxi").where("id", request.getParameter("id")).find(); %>


    <div class="container">
        <!-- 使用bootstrap css框架，container定宽，并剧中 https://v3.bootcss.com/css/#overview-container -->

        <div class="panel panel-default">
            <div class="panel-heading">添加学生成绩:</div>
            <div class="panel-body">
                <form action="xueshengchengji.jsp?a=insert" method="post" name="form1" id="form1">
                    <!-- form 标签开始 -->

                    <input type="hidden" name="kechengxinxiid"
                           value="<%= request.getParameter("id") !=null ? request.getParameter("id") : "" %>"/>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">课程编号</label>
                            <div class="col-sm-10"><%= readMap.get("kechengbianhao") %><input type="hidden"
                                                                                              id="kechengbianhao"
                                                                                              name="kechengbianhao"
                                                                                              value="<%= Info.html(readMap.get("kechengbianhao")) %>"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">课程名称</label>
                            <div class="col-sm-10"><%= readMap.get("kechengmingcheng") %><input type="hidden"
                                                                                                id="kechengmingcheng"
                                                                                                name="kechengmingcheng"
                                                                                                value="<%= Info.html(readMap.get("kechengmingcheng")) %>"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">科目</label>
                            <div class="col-sm-10"><% Map mapkemuxinxi55 = new CommDAO().find("SELECT kemumingcheng,id FROM kemuxinxi where id='" + readMap.get("kemu") + "'"); %>
                                <%= mapkemuxinxi55.get("kemumingcheng") %><input type="hidden" id="kemu" name="kemu"
                                                                                 value="<%= Info.html(readMap.get("kemu")) %>"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">学分</label>
                            <div class="col-sm-10"><%= readMap.get("xuefen") %><input type="hidden" id="xuefen"
                                                                                      name="xuefen"
                                                                                      value="<%= Info.html(readMap.get("xuefen")) %>"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">学生</label>
                            <div class="col-sm-10">
                                <div class="form-inline">
                                    <select
                                            class="form-control"
                                            data-fields="xuehao,xingming,xueqi,banji"
                                            id="xuesheng"
                                            name="xuesheng"
                                            onchange="getAjaxData('xueshengxinxi',this,this.value)"
                                    >
                                        <option value="">请选择学生</option>
                                    </select>

                                    <select class="form-control class_xueqi_search42" data-value="" id="xueqi_search"
                                            name="xueqi_search">
                                        <option value="">请选择</option>
                                        <% List<Map> select = new CommDAO().select("SELECT * FROM xueqixinxi ORDER BY id desc"); %>
                                        <% for (Map m : select) { %>

                                        <option value="<%= m.get("id") %>"><%= m.get("xueqimingcheng") %>
                                        </option>
                                        <%} %>

                                    </select>
                                    <select class="form-control class_banji_search43" data-value="" id="banji_search"
                                            name="banji_search">
                                        <option value="">请选择</option>
                                        <% select = new CommDAO().select("SELECT * FROM banjixinxi ORDER BY id desc"); %>
                                        <% for (Map m : select) { %>

                                        <option value="<%= m.get("id") %>"><%= m.get("banjimingcheng") %>
                                        </option>
                                        <%} %>

                                    </select>
                                    <button type="button" class="btn btn-default" onclick="xuesheng_select_update()">
                                        搜索
                                    </button>
                                    <script>
                                        function xuesheng_select_update() {
                                            var keyword = $("#xuesheng_keyword").val();
                                            var where = {};
                                            where.banji ="<%=session.getAttribute("banji")%>";
                                            if ($("#xueqi_search").val() != "") where.xueqi = $("#xueqi_search").val();
                                            if ($("#banji_search").val() != "") where.banji = $("#banji_search").val();
                                            searchSelect("xuesheng", "xueshengxinxi", keyword, where, "xuehao,xingming,xueqi,banji".split(","), "".split(","));
                                        }

                                        xuesheng_select_update();
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">学号</label>
                            <div class="col-sm-10">
                                <input
                                        type="text"
                                        class="form-control select-update"
                                        placeholder="输入学号"
                                        style="width: 150px"
                                        readonly="readonly"
                                        id="xuehao"
                                        name="xuehao"
                                        value="<%= request.getSession().getAttribute("username") !=null ? request.getSession().getAttribute("username") : "" %>"
                                />
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">姓名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control select-update" placeholder="输入姓名"
                                       style="width: 150px" id="xingming" name="xingming" value=""/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">学期</label>
                            <div class="col-sm-10">
                                <select class="form-control select-update" data-value="" id="xueqi" name="xueqi"
                                        style="width: 250px">
                                    <% select = new CommDAO().select("SELECT * FROM xueqixinxi ORDER BY id desc"); %>
                                    <% for (Map m : select) { %>

                                    <option value="<%= m.get("id") %>"><%= m.get("xueqimingcheng") %>
                                    </option>
                                    <%} %>

                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">班级</label>
                            <div class="col-sm-10">
                                <select class="form-control select-update" data-value="" id="banji" name="banji"
                                        style="width: 250px">
                                    <% select = new CommDAO().select("SELECT * FROM banjixinxi ORDER BY id desc"); %>
                                    <% for (Map m : select) { %>

                                    <option value="<%= m.get("id") %>"><%= m.get("banjimingcheng") %>
                                    </option>
                                    <%} %>

                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">成绩<span
                                    style="color: red">*</span></label>
                            <div class="col-sm-10">
                                <input
                                        type="number"
                                        class="form-control"
                                        placeholder="输入成绩"
                                        style="width: 150px"
                                        data-rule-required="true"
                                        data-msg-required="请填写成绩"
                                        number="true"
                                        data-msg-number="输入一个有效数字"
                                        id="chengji"
                                        name="chengji"
                                        value=""
                                />
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">评语</label>
                            <div class="col-sm-10">
                                <textarea style="width: 80%; height: 120px" class="form-control" placeholder="输入评语"
                                          id="pingyu" name="pingyu"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs">教师</label>
                            <div class="col-sm-10">
                                <input
                                        type="text"
                                        class="form-control"
                                        placeholder="输入教师"
                                        style="width: 150px"
                                        readonly="readonly"
                                        id="jiaoshi"
                                        name="jiaoshi"
                                        value="<%= request.getSession().getAttribute("username") !=null ? request.getSession().getAttribute("username") : "" %>"
                                />
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="text-align: right" class="col-sm-2 hiddex-xs"> </label>
                            <div class="col-sm-10">
                                <input name="referer" id="referers" class="referers"
                                       value="<%=request.getHeader("referer") %>" type="hidden"/>
                                <script>
                                    $(function () {
                                        $("input.referers").val(document.referrer);
                                    });
                                </script>

                                <button type="submit" class="btn btn-primary" name="Submit">提交</button>
                                <button type="reset" class="btn btn-default" name="Submit2">重置</button>
                            </div>
                        </div>
                    </div>

                    <!--form标签结束-->
                </form>
            </div>
        </div>

        <!-- container定宽，并剧中结束 -->
    </div>

    <script>
        $(function () {
            $("#form1").validate();
        });
    </script>
</div>
<%@ include file="foot.jsp" %>

